#include <stdlib.h>
#include "iostream.h"
#include "iomanip.h"

bool query(char const* s)
{
  if(!cin)
    exit(1);

  cout << "Test " << s << " (y/n) ";
  char reply;
  cin >> reply;

  cout << endl;

  return reply == 'y' || reply == 'Y';
}

int main()
{
  int count;

  if(query("strings"))
  {
    cout << "Type in some strings" << endl;
    for(count = 0; count < 16; ++count)
    {
      char s[256];
      cout << ">> ";
      if(cin >> s)
        cout << "<< |" << s << "|" << endl;
      else
      {
        cout << "cin failed" << endl;
        break;
      }
    }
  }

  if(query("decimal integers"))
  {
    cout << "Type in some decimal integers" << endl;
    cin >> setbase(10);
    for(count = 0; count < 16; ++count)
    {
      int i;
      cout << ">> ";
      if(cin >> i)
        cout << "<< " << i << endl;
      else
      {
        cout << "cin failed" << endl;
        break;
      }
    }
  }

  if(query("octal integers"))
  {
    cout << "Type in some octal integers" << endl;
    cin >> setbase(8);
    for(count = 0; count < 16; ++count)
    {
      int i;
      cout << ">> ";
      if(cin >> i)
        cout << "<< " << i << endl;
      else
      {
        cout << "cin failed" << endl;
        break;
      }
    }
  }

  if(query("hexadecimal integers"))
  {
    cout << "Type in some hexadecimal integers" << endl;
    cin >> setbase(16);
    for(count = 0; count < 16; ++count)
    {
      int i;
      cout << ">> ";
      if(cin >> i)
        cout << "<< " << i << endl;
      else
      {
        cout << "cin failed" << endl;
        break;
      }
    }
  }

  if(query("based integers"))
  {
    cout << "Type in some based integers" << endl;
    cin >> resetiosflags(ios::basefield);
    for(count = 0; count < 16; ++count)
    {
      int i;
      cout << ">> ";
      if(cin >> i)
        cout << "<< " << i << endl;
      else
      {
        cout << "cin failed" << endl;
        break;
      }
    }
  }

  if(query("floats"))
  {
    cout << "Type in some floats" << endl;
    cin >> resetiosflags(ios::basefield);
    for(count = 0; count < 16; ++count)
    {
      double d;
      cout << ">> ";
      if(cin >> d)
        cout << "<< " << d << endl;
      else
      {
        cout << "cin failed" << endl;
        break;
      }
    }
  }
}
